package cn.zyy.hotel.service.impl;

import cn.zyy.hotel.dao.DeptMapper;
import cn.zyy.hotel.entity.Dept;
import cn.zyy.hotel.service.DeptService;
import cn.zyy.hotel.vo.DeptVO;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
@Transactional
public class DeptServiceImpl implements DeptService {

    @Resource
    private DeptMapper deptMapper;

    //查询部门列表
    public List<Dept> selectDeptListByPage(DeptVO deptVo) {
        return deptMapper.selectDeptListByPage(deptVo);
    }

    //添加部门
    public int addDept(Dept dept) {
        //保存创建时间
        dept.setCreateDate(new Date());
        return deptMapper.addDept(dept);
    }

    //修改部门
    public int updateDept(Dept dept) {
        return deptMapper.updateDept(dept);
    }

    //删除部门
    public int deleteById(Integer id) {
        return deptMapper.deleteById(id);
    }

    //查询所有部门
    public List<Dept> selectDeptList() {
        return deptMapper.selectDeptList();
    }


}
